home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / shape.lha / shape / shape.c < prev    next >
Text File  |  1993-08-08  |  796b  |  52 lines

  1. include "shape.h"
  2. include "screen.h"
  3.  
  4. hape_lst shape_list;
  5.  
  6. ectangle::rectangle(point a, point b)
  7.  
  8.    if (a.x <= b.x) {
  9.        if (a.y <= b.y) {
  10.     sw = a;
  11.     ne = b;
  12. } else {
  13.     sw = point(a.x, b.y);
  14.     ne = point(b.x, a.y);
  15. }
  16.    } else {
  17.        if (a.y <= b.y) {
  18.     sw = point(b.x, a.y);
  19.     ne = point(a.x, b.y);
  20. } else {
  21.     sw = b;
  22.     ne = a;
  23. }
  24.    }
  25.  
  26.  
  27. oid rectangle::draw()
  28.  
  29.    point nw(sw.x, ne.y);
  30.    point se(ne.x, sw.y);
  31.    put_line(nw,ne);
  32.    put_line(ne,se);
  33.    put_line(se,sw);
  34.    put_line(sw,nw);
  35.  
  36.  
  37. oid shape_refresh()
  38.  
  39.    screen_clear();
  40.    sl_iterator next(shape_list);
  41.    shape* p;
  42.    while (p = next() ) p->draw();
  43.    screen_refresh();
  44.  
  45.  
  46. oid stack(shape* q, shape* p) // put p on top of q
  47.  
  48.    point n = p->north();
  49.    point s = q->south();
  50.    q->move(n.x-s.x, n.y-s.y+1);
  51.  
  52.